<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>社团小程序后台管理登录</title>
    <script type="text/javascript" src="${rc.contextPath}/static/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/static/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/static/css/login.css">
    <script>
        layui.use(['element', 'form', 'layer', 'table'], function () {
            var element = layui.element;
            var form = layui.form;
            var layer = layui.layer;
            var table = layui.table;
            
          	//密码隐藏/可见
            $('.bind-password').on('click', function () {
                if ($(this).hasClass('icon-5')) {
                    $(this).removeClass('icon-5');
                    $("input[name='password']").attr('type', 'password');
                } else {
                    $(this).addClass('icon-5');
                    $("input[name='password']").attr('type', 'text');
                }
            });
            
            form.on('submit(login)',function(data){
            	$.ajax({
        			url : "${rc.contextPath}/admin/vlogin",
        			type : "post",
        			dataType : "json",
        			data : data.field,
        			success : function(data, textStatus, jqXHR) {
        				if (data.code == 1) {
        					layer.msg("登录验证成功!", {
        						icon : 1,
        						time : 1000
        					}, function() {
        						location.href = "${rc.contextPath}/admin/index.html";
        					});
        				} else {
        					layer.msg(data.msg);
        				}
        			},
        			error : function(XMLHttpRequest, textStatus, errorThrown) {
        				layer.msg("请求服务器异常!");
        			}
        		});
            	return false;
            });
            
        });
    </script>
</head>
<body>
	<div class="main-body">
	    <div class="login-main">
	        <div class="login-top">
	            <span>社团小程序后台登录</span>
	            <span class="bg1"></span>
	            <span class="bg2"></span>
	        </div>
	        <form class="layui-form login-bottom">
	            <div class="center">
	                <div class="item">
	                    <span class="icon icon-2"></span>
	                    <input type="text" name="code" value="admin"
	                    	   lay-verify="required" lay-verType="tips" lay-reqText="账号不能非空"
	                           placeholder="请输入登录账号" autocomplete="off" maxlength="24"/>
	                </div>
	
	                <div class="item">
	                    <span class="icon icon-3"></span>
	                    <input type="password" name="password" value="123456"
	                           lay-verify="required" lay-verType="tips" lay-reqText="密码不能为空"
	                           placeholder="请输入密码" autocomplete="off" maxlength="20"/>
	                    <span class="bind-password icon icon-4"></span>
	                </div>
	
	            </div>
	            <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
	                <button class="login-btn" lay-submit="" lay-filter="login">立即登录</button>
	            </div>
	        </form>
	    </div>
	</div>
</body>
</html>

